using UnityEngine;

public class Game : MonoBehaviour {
    private GameObject _player;

    private void Start() {
        var req = Resources.LoadAsync<GameObject>("Player/Player");
        if (req != null)
            req.completed += PlayerLoaded;
    }

    private void OnDestroy() {
        _player = null;

        Resources.UnloadUnusedAssets();
    }

    private void PlayerLoaded(AsyncOperation op) {
        ResourceRequest req = op as ResourceRequest;
        if (req.isDone)
            _player = Instantiate(req.asset as GameObject);
    }
}
